package cn.xopencode.oss.dal.mysql.mapper.permission;

import cn.xopencode.mybatis.core.query.QueryWrapperX;
import cn.xopencode.oss.dal.mysql.dataobject.permission.PositionDO;
import cn.xopencode.oss.service.permission.bo.PositionPageBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;

@Repository
public interface PositionMapper extends BaseMapper<PositionDO> {

    default IPage<PositionDO> selectPage(PositionPageBO pageBO) {
        return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
                new QueryWrapperX<PositionDO>().likeIfPresent("post_name", pageBO.getPositionName()));
    }

//    default List<PositionDO> selectListByIds(Collection<Integer> ids) {
//        return selectList(new QueryWrapperX<PositionDO>().inIfPresent("id", ids));
//    }

    default PositionDO selectByName(String name) {
        return selectOne(new QueryWrapperX<PositionDO>().eqIfPresent("post_name", name));
    }

    default PositionDO selectByCode(String code) {
        return selectOne(new QueryWrapperX<PositionDO>().eqIfPresent("code", code));
    }

}
